<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home/welcome' }"
        >首页</el-breadcrumb-item
      >
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card class="box-card">
      <el-table border style="width: 100%" :data="authList">
        <el-table-column prop="index" type="index" label="序号" width="50">
        </el-table-column>
        <el-table-column prop="authName" label="权限名称" min-width="300px">
        </el-table-column>
        <el-table-column prop="path" label="权限路径" min-width="300px">
        </el-table-column>
        <el-table-column label="权限等级" min-width="300px">
          <template v-slot:default="{row}">
            <el-tag 
              effect="dark"
              :type="items[row.level].type"
            >
            {{items[row.level].label}}
            </el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      authList: [],
      items: [
        { type: "", label: "一级" },
        { type: "success", label: "二级" },
        { type: "warning", label: "三级" },
      ],
    };
  },
  methods: {
    async initAuthList() {
      try {
        let result = await this.$api.getAuthList();
        console.log(result);
        if (result == "error") return;

        this.authList = result;
      } catch (error) {
        console.log("权限列表加载错误：", error);
      }
    },
  },
  created() {
    this.initAuthList();
  },
};
</script>


<style lang="less" scoped>
.el-breadcrumb {
  margin-top: 6px;
  margin-bottom: 20px;
}
</style>